<?php
/*
 * 管理菜单
 * file name：leftMenu.php
 * create time: 2007-04-12
 */

require_once("global.php");
require_once("functions/adminMenu.php");

$menuObj = new adminMenu;
//输出xml文件头
echo("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"); 
echo("<?xml-stylesheet type=\"text/xsl\" href=\"./js/xtree.xsl\" ?>\n");
echo("<xtree target=\"main\">\n");  
echo("<document>管理菜单</document>\n");

//$DB->debug = true;
$menu_str = "";
//组织控制菜单

//取得一级菜单
$rs_menu = $menuObj->getMenuList_1();

while(!$rs_menu->EOF) {

	$url_1 = $rs_menu->fields["am_url"];
	if($url_1 == "") $url_1 = "javascript:;";
	
	$menu_str_1 = "<node name='" . $rs_menu->fields["am_name"] . "' opened='" . $rs_menu->fields["am_opened"] . "' id='" . $rs_menu->fields["am_id"] . "' url='" . $url_1 . "' target='" . $rs_menu->fields["am_target"] . "'> \n";
	$menu_str_2 = "";

	//取得二级菜单
	$rs_menu_2 = $menuObj->getMenuList_2($rs_menu->fields["am_id"]);
	
	while(!$rs_menu_2->EOF) {

		$url_2 = $rs_menu_2->fields["am_url"];
		if($url_2 == "") $url_2 = "javascript:;";
		
		//取第三级菜单
		$rs_menu_3 = $menuObj->getMenuList_3($rs_menu_2->fields["am_id"]);

		$menu_str_3 = "";
		while(!$rs_menu_3->EOF) {
			$url_3 = $rs_menu_3->fields["am_url"];
			if($url_3 == "") $url_3 = "javascript:;";
			$menu_str_3 .= "\t\t <document url='" . $url_3 ."' target='" . $rs_menu_3->fields["am_target"] . "'>" . $rs_menu_3->fields["am_name"] . "</document> \n";
			$rs_menu_3->MoveNext();
		}
		//
		
		if(!empty($menu_str_3)){
			$menu_str_2 .= "\t <node name='" . $rs_menu_2->fields["am_name"]. "' opened='". $rs_menu_2->fields["am_opened"] . "' id='".$rs_menu_2->fields["am_id"]."' url='" . $url_2 ."' target='" . $rs_menu_2->fields["am_target"] . "'>\n";
			$menu_str_2 .= $menu_str_3;
			$menu_str_2 .= "\t </node> \n";
		}else{
			$menu_str_2 .= "\t <document url='" . $url_2 . "' target='" . $rs_menu_2->fields["am_target"] . "'>" . $rs_menu_2->fields["am_name"] . "</document> \n";							
		}
		$rs_menu_2->MoveNext();
	}
	$menu_str .= $menu_str_1;
	$menu_str .= $menu_str_2;
	$menu_str .= "</node> \n";

	$rs_menu->MoveNext();
}

$menu_str .= "<node name='退出管理' opened='1' url='logout.php' target='_top'></node> ";
//输出控制菜单
echo($menu_str);
echo("</xtree>");
?>